import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'
import FileStorage from '../views/FileStorage.vue'
import FileTransfer from '../views/FileTransfer.vue'
import FileStorageDetail from '../views/FileStorageDetail.vue'
import FileTransferDetail from '../views/FileTransferDetail.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: { title: '首页 - File To Code' }
  },
  {
    path: '/storage',
    name: 'FileStorage',
    component: FileStorage,
    meta: { title: '文件货柜 - File To Code' }
  },
  {
    path: '/storage/detail/:id',
    name: 'FileStorageDetail',
    component: FileStorageDetail,
    meta: { title: '文件详情 - File To Code' }
  },
  {
    path: '/transfer',
    name: 'FileTransfer',
    component: FileTransfer,
    meta: { title: '文件速递 - File To Code' }
  },
  {
    path: '/transfer/detail',
    name: 'FileTransferDetail',
    component: FileTransferDetail,
    meta: { title: '文件详情 - File To Code' }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || 'File To Code'
  next()
})

export default router

